<template>
  <div>
    <van-nav-bar
        title='设置'
        placeholder
        fixed
        left-arrow
        @click-left="goBack"
    />
      <van-form>
        <van-cell title="个人资料设置" is-link :to="{path:'/user-edit',query:{user_id:this.user.id}}" />
        <van-cell title="地址管理" is-link :to="{path:'/address-edit',query:{user_id:this.user.id}}" />
        <van-cell title="账号与安全" is-link :to="{path:'/account-safety',query:{user_id:this.user.id}}" />
      </van-form>
    <van-button type="danger" size="large"
                style="width: 250px;border-radius: 4%;margin-left: 65px;margin-top: 10px"
                @click="logout">
      退出登录
    </van-button>
  </div>
</template>
<style>
#app{
  text-align: unset;
}
</style>

<script>

export default {
  data() {
    return {
      user:this.$store.state.userinfo.user?this.$store.state.userinfo.user.user:'',
      show:false,
      user_id:'',
    }
  },
  methods: {
    goBack() {
      this.$router.push("person");
    },
    logout(){
      //清空vuex中的数据
      this.$store.dispatch('userinfo/clearnuserinfo');
      //跳转登录页面
      this.$router.replace({path:'/login'})
    }
  },
  created() {
    this.user_id = this.$route.query.user_id
  }
}
</script>

<style scoped>

</style>